def valid_isbn_10(isbn):
    isbn = isbn.upper()
    val = 11 - (sum(map(lambda a,b: a * b, range(10,1,-1), 
    [int(i) for i in list(isbn.replace('-', '')[:-1])])) % 11)
    val = 'X' if val == 10 else val
    return (str(val) == isbn[-1])

def valid_isbn_13(isbn):
    val = (10 - (sum(map(lambda a,b: a * b, (1,3,1,3,1,3,1,3,1,3,1,3), 
    [int(i) for i in list(isbn.replace('-', ''))][:-1])) % 10)) % 10
    return (int(isbn[:3]) in [978, 979] and val == int(isbn[-1]))

def convert(item, ruleset):
    # Generate the formatted attributes for the item
    attr = {}

    # Iterate the ruleset for the Google Products API
    for rule, conf in ruleset.items():
        # There are no conditions for this rule
        if conf['cond'] is None:
            attr[rule] = conf['cnvt'](item)
        
        # The rule has a single functional condition (lambda)
        elif '__call__' in dir(conf['cond']):
            if conf['cond'](item): attr[rule] = conf['cnvt'](item)

        # The rule has set of conditions (list)
        elif isinstance(conf['cond'], list):
            count = 0
            for cond in conf['cond']:
                if not cond(item): break
                count = count + 1
            if count != len(conf['cond']): continue
            attr[rule] = conf['cnvt'](item)

        # The rule has a complex prefix/suffix ruleset (dictionary)
        elif isinstance(conf['cond'], dict):
            for adj, cond in conf['cond'].items():
                ordr = (adj, rule) if cond[0] else (rule, adj)
                name = '%s%s' % ordr
                if cond[1](item): attr[name] = conf['cnvt'](item)

    # Return the converted item's attributes
    return attr
